package com.googlecode.tabletags.views.freemarker.tags;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.opensymphony.xwork2.util.ValueStack;

/**
 * Provides @tt.tag access for various tags.
 *
 */
public class TableTagsModels {
    protected ValueStack stack;
    protected HttpServletRequest req;
    protected HttpServletResponse res;

    protected ColumnModel column;
    protected PagerModel pager;
    protected SortableHeaderModel sortableHeader;
    protected TableModel table;

    public TableTagsModels(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
        this.stack = stack;
        this.req = req;
        this.res = res;
    }

    public ColumnModel getColumn() {
        if (column == null) {
            column = new ColumnModel(stack, req, res);
        }
        return column;
    }

    public PagerModel getPager() {
        if (pager == null) {
            pager = new PagerModel(stack, req, res);
        }
        return pager;
    }

    public SortableHeaderModel getSortableHeader() {
        if (sortableHeader == null) {
            sortableHeader = new SortableHeaderModel(stack, req, res);
        }
        return sortableHeader;
    }
    
    public TableModel getTable() {
        if (table == null) {
            table = new TableModel(stack, req, res);
        }
        return table;
    }
}
